package com.shop.user.conf.util;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class MapUtil {

    public static Map<String, String> newStringMap(String mapType) {
        Map<String, String> map;
        switch (mapType) {
            case "hash":
                map = new HashMap<>();
                break;
            case "cHash":
                map = new ConcurrentHashMap<>();
                break;
            case "link":
                map = new LinkedHashMap<>();
                break;
            default:
                map = new HashMap<>();
                break;
        }
        return map;
    }

    public static <T> Map<String, T> newObjectMap(String mapType) {
        Map<String, T> map;
        switch (mapType) {
            case "hash":
                map = new HashMap<String, T>();
                break;
            case "cHash":
                map = new ConcurrentHashMap<String, T>();
                break;
            case "link":
                map = new LinkedHashMap<String, T>();
                break;
            default:
                map = new HashMap<String, T>();
                break;
        }
        return map;
    }
}
